package br.com.cs.helper;


import br.com.cs.exception.PojoException;
import br.com.cs.model.Visitante;
import br.com.cs.pojo.impl.VisitantePojoImpl;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

public class CategoriaConverter implements Converter {

    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        try {
            return VisitantePojoImpl.getInstance().getByPrimaryKey(Integer.valueOf(value));
        } catch (PojoException e) {
            e.printStackTrace();
            return null;
        }
    }

    public String getAsString(FacesContext context, UIComponent component, Object value) {
        Visitante c = (Visitante) value;
        return String.valueOf(c.getId());
    }

}
